<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         function Grand(){};
         function Parent(){};
         Grand.prototype.tskill = '拉二胡';
         var grand = new Grand();
         //Parent.prototype = grand;
         var parent = new Parent();
         parent.tskill = '弹琴';
         console.log(parent.tskill);
        console.log(grand.tskill);

         function Test(){
         this.name = name;
         this.age = age;
         }
        obj = {}
        //分别使用call，apply为obj添加name，age属性
        //Test.call(obj,name='张三',age=15);
        //Test.apply(obj,[name = '张三',age = 16]);

        //实现陈鹏买车，其中有sayHi方法，功能:打印'陈鹏买了一辆红色的2.0宝马车'
        // function People(name){
        //     this.name = name;
        // };
       
        // function Car(brand,color,power){
        //     this.brand = brand;
        //     this.color = color;
        //     this.power = power;
        // };
        // People.prototype = new Car('宝马','红色',2.0);
        // People.prototype.sayHi = function(){
        //     console.log(this.name + '买了一辆' + this.color + this.power + this.brand);
        // }
        // var cp = new People('cp');
        // cp.sayHi()
        //父类Shape （属性有:name,length,width,方法有:Intro 我是XX形）
        //子类： Circle(属性有:r)
        //分别使用 原型链继承 构造函数继承 圣杯继承

        //原型链继承
        // function Shape(name,length,width){
        //     this.name = name;
        //     this.length = length;
        //     this.width = width;
        // }
        // Shape.prototype.Intro = function(){
        //     console.log(this.name);
        // }
        // function Circle(r){
        //     this.r = r;
        // }
        // Circle.prototype = new Shape('圆形');
        // var circle = new Circle(1);
        // circle.Intro();

        //构造函数继承
        // function Shape(name,length,width){
        //     this.name = name;
        //     this.length = length;
        //     this.width = width;
        //     this.Intro = function(){
        //         console.log(this.name);
        //     } 
        // }
        // function Circle(r,name){
        //     Shape.call(this,name);
        //     this.r = r;
        // }
        // var circle = new Circle(1,'圆形');
        // circle.Intro();

        //圣杯继承
        // function Shape(){};
        // Shape.prototype.Intro = function(){
        //     console.log(this.name);
        // }
        // function Circle(){};
        // function inherit(Target,Origin){
        //     function F(){};
        //     F.prototype = Origin.prototype;
        //     Target.prototype = new F();
        //     Target.prototype.constructor = Target;
        //     Target.prototype.uber = Origin;
        // }
        // inherit(Circle,Shape);
        // var circle = new Circle();
        // circle.name = '圆形'
        // circle.Intro();
       
        

        
        
    </script>
</body>
</html>